package com.leyou.api.controller;

import com.leyou.common.dto.PageDTO;
import com.leyou.pojo.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@FeignClient("item-service")
public interface FeignController {


    /**
     * 分页查询spu
     * @param queryPageDto
     * @return
     */
    @GetMapping("/goods/spu/page")
    PageDTO<SpuDto> queryGoodsByPage(@SpringQueryMap QueryPageDto queryPageDto);


    /**
     * 根据商品id查询商品的详细信息
     * @param spuId
     * @return
     */
    @GetMapping("/goods/spu/detail")
     SpuDetailsDto querySpuDetail(@RequestParam("id") Long spuId);


    /**
     * 根据商品id查询商品
     * @param spuId
     * @return
     */
    @GetMapping("/goods/spu/{id}")
    SpuDto  querySpu(@PathVariable("id") Long spuId);


    /**
     * 根据id查询spu，spuDetail，sku三张表
     * @param spuId
     * @return
     */
    @GetMapping("/goods/{id}")
     SpuDto  querySkuAndSpuAndSpuDetail(@PathVariable("id") Long spuId);


    /**
     * 根据sku的id批量插叙sku
     * @param ids
     * @return
     */
    @GetMapping("/goods/sku/list")
   List<SkuDto>  querySku(@RequestParam("ids") List<Long> ids);

    /**
     * 根据spuId查询sku集合
     * @param spuId
     * @return
     */
    @GetMapping("/goods/sku/of/spu")
     List<SkuDto> querySkuBySpuId(@RequestParam("id") Long spuId);


    /**
     * 查询规格参数值
     * @param spuId
     * @param searching
     * @return
     */
    @GetMapping("/goods/spec/value")

    List<SpecParamDto> queryParamValue(@RequestParam("id") Long spuId,
                                                              @RequestParam(value = "searching",required = false) Boolean searching);


    /**
     * 根据品牌id查询规格组和规格参数
     * @param categoryId
     * @return
     */
    @GetMapping("/spec/list")
    public List<SpecGroupDto> querySpecGroupAndParamById(@RequestParam("id") Long categoryId);

    /**
     * 根据品牌id查询品牌
     * @param id
     * @return
     */
    @GetMapping("/brand/{id}")
    public BrandDto  queryBrandById(@PathVariable("id") Long id);

    @GetMapping("/category/list")
    public List<CategoryDto>  queryCategoriesByIds(@RequestParam("ids") List<Long> ids);
}
